Creating
a File-Handler Instance in a DLL
When an
application specifies your file-handler DLL or stream handler, the system looks
it up in the registry by its class identifier and loaded. The system then calls
the DllGetClassObject
// Main DLL entry point.
STDAPI DllGetClassObject(const CLSID FAR&
rclsid,
const IID
FAR& riid, void FAR* FAR* ppv)
{
HRESULT
hresult;
hresult =
CAVIFileCF::Create(rclsid, riid, ppv);
return
hresult;
}
HRESULT CAVIFileCF::Create(const CLSID FAR& rclsid,
const IID
FAR& riid, void FAR* FAR* ppv)
{
// The following is the class factory creation and
not an
// actual PAVIFile.
CAVIFileCF
FAR* pAVIFileCF;
IUnknown
FAR* pUnknown;
HRESULT
hresult;
// Create the instance.
pAVIFileCF
= new FAR CAVIFileCF(rclsid, &pUnknown);
if
(pAVIFileCF == NULL)
return
ResultFromScode(E_OUTOFMEMORY);
// Set the interface pointer.
hresult =
pUnknown->QueryInterface(riid, ppv);
if
(FAILED(GetScode(hresult)))
delete
pAVIFileCF;
return
hresult;
}